package cn.zd.demo1.broadcast;

import static cn.zd.demo1.broadcast.MyBroadCastConstant.ACTION;
import static cn.zd.demo1.broadcast.MyBroadCastConstant.ACTION_SOCK;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Vibrator;
import android.widget.Toast;

public class MyStaticReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent != null && intent.getAction().equals(ACTION_SOCK)) {
            // 获取震动管理器
            Vibrator service = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
            // 震动
            service.vibrate(1000);
            Toast.makeText(context,"接收到静态注册广播",Toast.LENGTH_SHORT).show();
        }
    }
}